﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using GenericLibrariesToolKit;
using GenericLibrariesToolKit.Enumeration;
using Model;
using BLL.Info;
using BLL.Info.Impl;
using Utils;
public partial class Page_Publications_PublicationInfo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack&&Request["publicationID"] != null)
        {
            string publicationID = Request["publicationID"].ToString();
            showPublicationInfo(publicationID);
            addClickAmount(publicationID);
        }
        
    }
    public void showPublicationInfo(string publicationID)
    {
        //设置where查询条件
        WhereCondition[] whereCondition = new WhereCondition[]
        {
            new WhereCondition(WhereJoinType.NULL,"PublicationId",MatchType.EQUAL,publicationID),
        };
        PublicationBO publicationBO = new PublicationBOImpl();
        //执行sql查询语句
        DataSet resultNews = publicationBO.GetDataSet(-1, -1, whereCondition);
        //绑定数据源
        dvPublicationInfo.DataSource = resultNews;
        dvPublicationInfo.DataBind();

    }
    //返回上一页面
    protected void btnPublicationInfoBack_Click(object sender, ImageClickEventArgs e)
    {
        Response.Write("<script language=javascript>history.go(-2);</script>");
    }
    /// <summary>
    /// 对该出版物的点击量加1
    /// </summary>
    private void addClickAmount(string publicationID)
    {
       
        PublicationBO publicationBO = new PublicationBOImpl();
        Publication publication = publicationBO.Find(publicationID);
        publication.PublicationClickAmount++;       
        publicationBO.Update(publication);

    }
}